﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClientInfrastructure.Util.Helper
{
    public class AutoMapperHelper
    {
        static Mapper? mapper = null;
        public static void Start(MapperConfiguration configuration)
        {
            mapper = new Mapper(configuration);
        }
        public static T? Map<S, T>(S soure)
        {
            if (mapper == null) return default;

            T to = mapper.Map<S, T>(soure);
            return to;
        }

        public static T? Map<T>(object soure)
        {
            if (mapper == null) return default;
            T to = mapper.Map<T>(soure);
            return to;
        }

        public static TDestination? Map<TSource, TDestination>(TSource source, TDestination destination)
        {
            if (mapper == null) return default;
            TDestination to = mapper.Map<TSource, TDestination>(source, destination);
            return to;
        }
    }

}
